package common.server.http;

import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;

/**
 *  HLJ HTTP ServletInputStream
 * @author Administrator
 * @version [版本号, 2017/12/28 0028]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
public class ServletInputStreamWrapper extends ServletInputStream {
    private ByteArrayInputStream inputStream;

    public ServletInputStreamWrapper(byte[] data){
        this.inputStream = new ByteArrayInputStream( data );
    }

    @Override
    public int available() throws IOException {
        return inputStream.available();
    }
    @Override
    public int read() throws IOException {
        return inputStream.read();
    }
    @Override
    public int read(byte[] b, int off, int len) throws IOException {
        return inputStream.read( b, off, len );
    }

    @Override
    public boolean isFinished() {
        return false;
    }

    @Override
    public boolean isReady() {
        return false;
    }

    @Override
    public void setReadListener(ReadListener readListener) {

    }
}
